package thread;

public class SyncApiDemo {
    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();
        Thread t1 = new Thread(){
            @Override
            public void run(){
                    for (int i = 0; i < 100; i++) {
                        sb.append("abc");
                    }
            }
        };
        Thread t2 = new Thread(){
            @Override
            public void run(){
                    for (int i = 0; i < 100; i++) {
                        sb.append("def");
                    }
            }
        };
        t1.start();
        t2.start();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(sb);
    }
}
